package org.Lin.service;

import org.Lin.dao.OperationLogDAO;
import org.Lin.model.OperationLog;

import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.List;

public class LogService {

    private final OperationLogDAO operationLogDAO = new OperationLogDAO();

    public void recordLog(String object, String code, String content) {
        try {
            OperationLog log = new OperationLog();
            log.setOperationObject(object);
            log.setOperationCode(code);
            log.setOperationContent(content);
            log.setOperationTime(LocalDateTime.now());
            operationLogDAO.insert(log);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public List<OperationLog> getAllLogs() throws SQLException {
        return operationLogDAO.findAll();
    }
}
